// 封装请求函数
import config from './config';
import getLatestUserInfo from './getLatestUserInfo.js';

export default (url, data={},method='GET') => {
	// data.token = uni.getStorageSync('token');
	return new Promise((resolve, reject)=>{
		uni.request({
		    url: config.host + url, 
		    data,
			method,
		    header: { Authorization: uni.getStorageSync('token') },
		    success: async res => {
				let result = await getLatestUserInfo();
				// console.log(result);
				if(result.code){
					resolve(res.data);
				}
		    }
		});
	});
};